<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:c="http://java.sun.com/jsp/jstl/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	template="/WEB-INF/layout/t.xhtml">

	<ui:define name="title">
		<h:outputText value="Lista Prodotti Catalogo" />
	</ui:define>
	<ui:define name="roles">
		<f:attribute name="roles" value="catalogue" />
	</ui:define>
	<ui:define name="content">
		<h:form acceptcharset="UTF-8">
			<center>
				<p:panel header="Lista Prodotti">
					<h:panelGrid columns="7">
						<h:outputLabel for="name" value="Nome:" />
						<h:inputText id="name"
							value="#{productController.search.obj.name}" />

						<h:outputLabel for="code" value="Codice:" />
						<h:inputText id="code"
							value="#{productController.search.obj.code}" />

						<h:outputLabel for="tipo" value="Seleziona categoria:" />
						<h:selectOneMenu id="tipo"
							value="#{productController.search.obj.category.id}">
							<f:selectItems value="#{categoryItems}" />
						</h:selectOneMenu>
						<h:commandButton action="#{productController.reloadAjax}"
							value="Cerca" />
					</h:panelGrid>
					<br />

					<p:dataTable id="newsList" rowIndexVar="rowIndex" var="product"
						value="#{productController.model}"
						rows="#{productController.pageSize}" paginator="true"
						dynamic="true">
						<p:column width="50">
							<h:outputText value="#{rowIndex+1}" />
						</p:column>

						<p:column width="300">
							<f:facet name="header">nome</f:facet>
							<h:outputText value="#{product.name}" />
						</p:column>

						<p:column width="300">
							<f:facet name="header">codice</f:facet>
							<h:outputText value="#{product.code}" />
						</p:column>

						<p:column width="300">
							<f:facet name="header">anteprima</f:facet>
							<h:outputText value="#{product.preview}" />
						</p:column>

						<p:column width="100">
							<f:facet name="header">categoria</f:facet>
							<h:outputText value="#{product.category.name}" />
						</p:column>

						<p:column width="100">
							<f:facet name="header">operazioni</f:facet>
							<center>
								<h:commandLink action="#{productController.viewElement}"
									value="vedi" />
								-
								<h:commandLink action="#{productController.modElement}"
									value="modifica" />
							</center>
						</p:column>
					</p:dataTable>
				</p:panel>
				<br /> <br />

				<h:panelGrid columns="1">
					<h:commandButton id="add" action="#{productController.addElement}"
						value="Aggiungi" />
				</h:panelGrid>
			</center>
		</h:form>
	</ui:define>
</ui:composition>